package com.example.shushiyunsst.fragment.main.home.recycler.provider;

import android.content.Context;
import android.view.View;

import com.example.library_common.adapter.multi.AdapterViewItemViewClick;
import com.example.library_common.adapter.multi.JssMultiItemViewHolder;
import com.example.library_common.adapter.multi.JssNewMultipleAdapter;
import com.example.library_common.album.view.grid_view.XGridLayout;
import com.example.library_common.album.view.grid_view.adapter.CommAdapter;
import com.example.library_common.album.view.grid_view.adapter.XQuickViewHolder;
import com.example.shushiyunsst.R;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.MinerEntity;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.MinerEntityWrapper;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.ShopListEntity;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.ShopListEntityWrapper;

import java.util.List;

public class ShopListProvider extends JssMultiItemViewHolder<ShopListEntity> {

//    private CommAdapter<ShopListEntity> mAdapter;

    @Override
    public int getItemLayout() {
        return R.layout.shop_list_provider_item_layout;
//        return R.layout.shop_list_provider_layout;
    }

    public ShopListProvider(View view) {
        super(view);
    }

    @Override
    public void convert(Context context, ShopListEntity mEntityWrapper) {
        super.convert(context, mEntityWrapper);

        setText(R.id.titleTv, mEntityWrapper.getTitle())
                .setText(R.id.priceEtv, String.valueOf(mEntityWrapper.getPriceYS()))
                .setImageNetUrl(R.id.goodsImg, mEntityWrapper.getModUrl(), R.mipmap.image_load_err)
                .setText(R.id.fu_lu_ji_fen, String.valueOf(mEntityWrapper.getIntegral()));

        findView22(R.id.shopFrame).setOnClickListener(v -> {
            if (adapter instanceof JssNewMultipleAdapter) {
                AdapterViewItemViewClick itemViewClick =
                        ((JssNewMultipleAdapter) adapter).getAdapterViewItemViewClick();
                if (itemViewClick != null) {
                    itemViewClick.onAdapterViewListItemViewClick(mEntityWrapper, mEntityWrapper.getItemType());
                }
            }
        });

//        XGridLayout mLineLayout = findView(R.id.mLineLayout);
//        if (mAdapter == null) {
//            mAdapter = new CommAdapter<ShopListEntity>(
//                    context,
//                    R.layout.shop_list_provider_item_layout
//            ) {
//                @Override
//                public void convert(XQuickViewHolder holder, ShopListEntity item, int position) {
//                    holder.setText(R.id.titleTv, item.getTitle())
//                            .setText(R.id.priceEtv, String.valueOf(item.getPriceYS()))
//                            .displayImage(R.id.goodsImg, item.getModUrl(), R.mipmap.image_load_err)
//                            .setText(R.id.fu_lu_ji_fen, String.valueOf(item.getIntegral()))
//                            .setOnClickListener(v -> {
//                                if (adapter instanceof JssNewMultipleAdapter) {
//                                    AdapterViewItemViewClick itemViewClick =
//                                            ((JssNewMultipleAdapter) adapter).getAdapterViewItemViewClick();
//                                    if (itemViewClick != null) {
//                                        itemViewClick.onAdapterViewListItemViewClick(item,item.getItemType());
//                                    }
//                                }
//                            });
//
//                }
//            };
//        }
//        if (mLineLayout != null) {
//            if (adapter instanceof JssNewMultipleAdapter) {
//                mLineLayout.setAdapter(mAdapter, ((JssNewMultipleAdapter) adapter).getLifecycle());
//            }
//        }
//        List<ShopListEntity> list = mEntityWrapper.getList();
//
//        mAdapter.clear();
//        mAdapter.addAll(list);
    }
}
